package jsj.myjdbc;

import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Regist extends JFrame implements ActionListener {
	JPanel p;
	JLabel lblName,lblPwd,lblRePwd,lblSex,lblLike,lblAddr,lblDegree;
	JTextField txtName;
	JPasswordField txtPwd,txtRePwd;
	JRadioButton rbMale,rbFemale;
	JCheckBox ckbRead,ckbNet,ckbSwim,ckbtour;
	JTextArea txtAddr;
	JComboBox cmbDegree;
	JButton btnOk,btnCancle;
	
	public Regist(){
		p = new JPanel(new GridLayout(8, 1));
		lblName = new JLabel("�û���");
		lblPwd = new JLabel("��    ��");
		lblRePwd = new JLabel("ȷ������");
		lblSex = new JLabel("�Ա�");
		lblLike = new JLabel("����");
		lblAddr = new JLabel("��ַ");
		lblDegree = new JLabel("ѧ��");
		txtName = new JTextField(20);
		txtPwd = new JPasswordField(20);
		txtRePwd = new JPasswordField(20);
		rbMale = new JRadioButton("��");
		rbFemale = new JRadioButton("Ů");
		ckbRead = new JCheckBox("�Ķ�");
		ckbNet = new JCheckBox("����");
		ckbSwim = new JCheckBox("��Ӿ");
		ckbtour = new JCheckBox("����");
		txtAddr = new JTextArea(3,20);
		String[] str = {"小学","中学","大学","研究生","博士"};
		cmbDegree = new JComboBox(str);
		cmbDegree.setEditable(true);
		btnOk = new JButton("OK");
		btnCancle = new JButton("cancel");
		btnOk.addActionListener(this);
		btnCancle.addActionListener(this);
		ButtonGroup bg = new ButtonGroup();
		bg.add(rbMale);
		bg.add(rbFemale);
		JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p1.add(lblName);
		p1.add(txtName);
		p.add(p1);
		JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p2.add(lblPwd);
		p2.add(txtPwd);
		p.add(p2);
		JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p3.add(lblRePwd);
		p3.add(txtRePwd);
		p.add(p3);
		JPanel p4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p4.add(lblSex);
		p4.add(rbMale);
		p4.add(rbFemale);
		p.add(p4);
		JPanel p5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p5.add(lblLike);
		p5.add(ckbRead);
		p5.add(ckbNet);
		p5.add(ckbSwim);
		p5.add(ckbtour);
		p.add(p5);
		JPanel p6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p6.add(lblAddr);
		p6.add(txtAddr);
		p.add(p6);
		JPanel p7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		p7.add(lblDegree);
		p7.add(cmbDegree);
		p.add(p7);
		JPanel p8 = new JPanel(new FlowLayout(FlowLayout.CENTER));
		p8.add(btnOk);
		p8.add(btnCancle);
		p.add(p8);
		
		this.add(p);
		this.setBounds(100,100,400,500);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
	}
	
	public static void main(String[] args) {
		Regist f = new Regist();
		f.setVisible(true);
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnOk) {
			String degree = cmbDegree.getSelectedItem().toString();
			txtAddr.append(degree+"\n\r");
		}
		
		if(e.getSource() == btnCancle) {
			FrameShowData f = new FrameShowData();
			f.setVisible(true);
		}
		
	}
	

}
